using System.Collections.Generic;
using UnityEngine;

public enum EnemyTag{
    None = 0,
}

public class Enemy : Entity
{   
    public AI ai;
    [Tooltip("在创建时展示的图片")]
    public Sprite showOnCreat;
    //检测玩家
    public Trigger playerTrigger;
    [Tooltip("Disable")]
    public Player targetPlayer;
    public bool alwaysTargetPlayer = false;//无视检测器，总是跟踪玩家
    
    //近战碰撞伤害的子弹
    [Tooltip("Disable")]
    public Bullet melee;

    [SerializeField]
    private List<EnemyTag> enemyTags = new List<EnemyTag>();
    public bool CheckEnemyTag(EnemyTag t){
        return enemyTags.Contains(t);
    }
    
    /// <summary>
    /// 获取到玩家的向量,调用该方法才会从playerTrigger中获取玩家
    /// </summary>
    /// <returns></returns>
    public Vector2 ToPlayer(){
        if(alwaysTargetPlayer){
            targetPlayer = GameManager.instance.player;
            if(targetPlayer == null)
                return Vector2.zero;
            else
                return targetPlayer.transform.position - transform.position;
        }
        if(playerTrigger != null){
            targetPlayer = playerTrigger.targetPlayer;
            if(targetPlayer == null){
                return Vector2.zero;
            }else{
                targetPlayer = playerTrigger.targetPlayer;
                return targetPlayer.transform.position - transform.position;
            }
        }else{
            targetPlayer = null;
            return Vector2.zero;
        }
    }

    /*protected override void Init(){
        base.Init();
        melee = Bullet.CreatMeleeBullet(this);
    }*/
}
